package com.cndw.kungfu.model.pvp.api;

import java.util.Collection;

import com.cndw.kungfu.business.BusinessApiOnline;
import com.cndw.kungfu.model.activity.domain.CrossServer;

public class CommApiClient {

	public static void reloadServers() {
		ApiClient.load();
	}

	/**
	 * 献花全服广播
	 * 
	 * @param parms
	 */
	public static void allMessage(Object... parms) {
		ApiClient.areaMessage(0, ApiConfig.actCross, parms);
	}

	/**
	 * 主播在线统计
	 * 
	 * @return
	 */
	public static int allMJOnLine() {
		Collection<CrossServer> servers = CrossServer.getAll();
		String contrl = BusinessApiOnline.class.getSimpleName();
		String method = ApiConfig.getOnlineCounts;
		int allOnline = 0;
		for (CrossServer e : servers) {
			Object m = ApiClient.sendApiMByContrl(e.getServerId(), contrl, method, 1000, 11);
			if (m != null && m instanceof Integer) {
				allOnline += Integer.valueOf(m.toString());
			}
		}
		return allOnline;
	}

	public static int balefireSend(long uid, String name) {
		Object m = ApiClient.setdApi(ApiCore.crossSid(), ApiConfig.balefireSend, ApiCore.currentSid(), uid, name);
		if (m instanceof Integer) {
			return (Integer) m;
		}
		return -2;
	}

	public static int balefireState() {
		Object m = ApiClient.setdApi(ApiCore.crossSid(), ApiConfig.balefireState);
		if (m instanceof Integer) {
			return (Integer) m;
		}
		return 0;
	}

	public static void balefireAward(String idstr, String ticp) {
		ApiClient.areaMessage(0, ApiConfig.balefireAward, idstr, ticp);
	}

}
